#!/bin/bash

#arg1 timeout to wait before running the script
#arg2 interface
#arg3 iperf arguments

args=($*)
timeout=${args[0]}
iface=${args[1]}
iperf3_args=(${args[@]:2})

#array=${1:-1}
echo "args =  ${args[@]}"
echo "timeout = $timeout"
echo "iface = $iface"
echo "iperf3_args = ${iperf3_args[@]}"

sleep $timeout

while true; do var=`ifconfig $iface` ;sleep 1; if [ "$var" != "" ]; then break; fi ; done ; sleep 5

iperf3 ${iperf3_args[@]}
